<template>
    <div>
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class='["mui-control-item", item.id == 0 ? "mui-active" : ""]' v-for="item in imgFl" :key="item.id" @click="getphotolist(item.id)">
                        {{item.title}}
                    </a>
                </div>
            </div>
        </div>   


        <ul class="photo_con">
            <router-link :to="'/home/photoinfo/'+ item.id" tag="li" class="photo_item" v-for="item in photolist" :key="item.id">
                <img v-lazy="item.img_url">
                <div class="photo_info">
                    <h3>{{item.title}}</h3>
                    <p>{{item.zhaiyao}}</p>
                </div>
            </router-link>
        </ul>

        



    </div>
</template>
<script>
import { Toast } from 'mint-ui'
import mui from "../../lib/mui/js/mui.min.js"

export default {
    data() {
        return {
            imgFl:[], //图片分类
            photolist:[]//图片列表
        }
    },
    created() {
        this.getimgFl()
        this.getphotolist(0)
    },
    mounted() {
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        }); 
    },
    methods: {
        getimgFl(){
            this.$http.get("api/getimgcategory").then(res =>{
                if(res.body.status === 0){
                    res.body.message.unshift({"title":"全部","id":0})
                    this.imgFl = res.body.message
                }else{
                    Toast("failed")
                }
            })
        },
        getphotolist(flid){
            this.$http.get("api/getimages/" + flid).then(res =>{
                if(res.body.status === 0){
                    console.log(res.body.message)
                    this.photolist = res.body.message
                }else{
                    Toast("failed")
                }
            })
        }
    },
}
</script>
<style lang="scss" scoped>
*{
    touch-action: pan-y;
}

.photo_con{
    list-style: none;
    padding: 10px;
    margin: 0;
    padding-bottom: 0;
    .photo_item{
        background-color: #ccc;
        text-align:center;
        margin-bottom: 10px;
        box-shadow: 0 0 8px #666;
        position: relative;
    }
    img{
        width: 100%;
        vertical-align: middle;
    }
    .photo_info{
        background-color: rgba(0,0,0,0.4);
        position: absolute;
        bottom: 0;
        color: #fff;
        text-align: left;
        max-height: 84px;
        h3{
            font-size: 14px;
        }
        p{
            font-size: 12px;
            color: #fff;
        }
    }

    img[lazy=loading] {
    width: 40px;
    height: 300px;
    margin: auto;
    }
}

</style>
